package com.cskaoyan.mall.promo.converter;

import com.cskaoyan.mall.dto.ProductDetailDto;
import com.cskaoyan.mall.promo.dto.PromoItemInfoDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

@Mapper(componentModel = "spring")
public interface PromoInfoConverter {

    @Mappings({
            @Mapping(source = "productDetailDto.salePrice", target = "price"),
            @Mapping(source = "productDetailDto.productImageBig", target = "picUrl"),
            @Mapping(source = "productDetailDto.productId", target = "id"),
            @Mapping(source = "stock", target = "inventory"),
            @Mapping(source = "seckillPrice", target = "seckillPrice")
    })
    PromoItemInfoDto convert2InfoDto(ProductDetailDto productDetailDto, Integer stock, BigDecimal seckillPrice);
}